<?php

require_once('Zend/CodeGenerator/Php/Class.php');

class Zend_CodeGenerator_Php_Class_Db_Table extends Zend_CodeGenerator_Php_Class
{
	function __construct($spec=null) {
		
		$options = array(
			'Docblock' => array(
		        'shortDescription' => 'Sample generated class',
		        'longDescription'  => 'This is a class generated with Zend_CodeGenerator.',
		        'tags'             => array(
		            array(
		                'name'        => 'version',
		                'description' => '$Rev:$',
		            ),
		            array(
		                'name'        => 'license',
		                'description' => 'New BSD',
		            ),
		        ),
		    ),
		);
		$options = array_merge_recursive($options, $spec);
		parent::__construct($options);
		
	}
    public function setPrimary($pk) {
    	$primary = array();
    	foreach ($pk as $k) {
    		$primary[] = $k->getName();
    	}
    	$property = new Zend_CodeGenerator_Php_Property(array(
    		'name'         => '_primary',
            'visibility'   => 'protected',
            'defaultValue' => $primary,
    	));
    	$this->setProperty($property);
    	
    	return $this;
    }
    public function setDependentTables($tables) {
    	if (!empty($tables)) {
    		$arr = array();
    		foreach ($tables as $table) {
    			$arr[] = Zend_Mwb_Dom_Table::$defaultNamespace . $table->getClass();
    		}
	    	$property = new Zend_CodeGenerator_Php_Property(array(
	    		'name'         => '_dependentTables',
	            'visibility'   => 'protected',
	            'defaultValue' => $arr,//array('Application_Model_Table_*'),
	    	));
	    	$this->setProperty($property);
    	}
    	return $this;
    }
    public function setReferenceMap($referenceMap) {
    	if (!empty($referenceMap)) {
	    	$property = new Zend_CodeGenerator_Php_Property(array(
	    		'name'         => '_referenceMap',
	            'visibility'   => 'protected',
	            'defaultValue' => $referenceMap,
	    	));
	    	$this->setProperty($property);
    	}
    	return $this;
    }
}
